package main;


import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.media.opengl.GLCanvas;

public class JavaMain implements Runnable {
    public static Thread displayT = new Thread(new JavaMain());
    public static boolean bQuit = false;

    public static void main(final String[] args) {
        JavaMain.displayT.start();
    }

    public void run() {
        final Frame frame = new Frame("TP MITIC - MAR - OPENGL :)");
        final GLCanvas canvas = new GLCanvas();
        canvas.addGLEventListener(new JavaRenderer());

        frame.add(canvas);
        frame.setSize(1100, 700);
        // frame.setUndecorated(false);
        // frame.setUndecorated(true); // fullscreen
        final int size = frame.getExtendedState();
        // size |= Frame.MAXIMIZED_BOTH;
        frame.setExtendedState(size);

        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(final WindowEvent e) {
                JavaMain.bQuit = true;
                // displayT.interrupt();
                System.exit(0);
            }
        });
        frame.setVisible(true);
        canvas.requestFocus();
        while (!JavaMain.bQuit) {
            canvas.display();
        }
    }
}
